class Calculator {  
  def calculate(x: Int, y: Int, operator: Char): Any = {  
    operator match {  
      case '+' => x + y  
      case '-' => x - y  
      case '*' => x * y  
      case '/' if y != 0 => x / y  
      case _ => "Invalid operator"  
    }  
  }  
}  
  
// 示例用法  
object CalculatorApp {  
  def main(args: Array[String]): Unit = {  
    val calculator = new Calculator()  
  
    // 测试加法  
    println(calculator.calculate(5, 3, '+')) // 输出: 8  
  
    // 测试减法  
    println(calculator.calculate(5, 3, '-')) // 输出: 2  
  
    // 测试乘法  
    println(calculator.calculate(5, 3, '*')) // 输出: 15  
  
    // 测试除法  
    println(calculator.calculate(10, 2, '/')) // 输出: 5  
  
    // 测试无效操作符  
    println(calculator.calculate(5, 3, '%')) // 输出: Invalid operator  
  
    // 测试除数为0的情况  
    println(calculator.calculate(10, 0, '/')) // 输出: Invalid operator  
  }  
}